home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: October 24, 1996
- // Author: mm
- //
- // Description:
- // This a helper script which will add a given bookmark
- // to the mainListConnection of an editor.
- //
- // Input Arguments:
- // The name of the editor to modify
- // The name of the bookmark to connect
- // Flag to indicate use or detach
- //
- // Return Value:
- // None.
- //
-
- global proc
- useBookmark (string $editor, string $bookmark, int $use)
- {
- // Make sure the editor exists
- //
- if (!`editor -exists $editor`) {
- error "Editor not found";
- }
- // And make sure the bookmark exists
- //
- if (catch (`sets -query -text $bookmark`)) {
- error "Bookmark not found";
- }
- // First, find out what is connected to this editor
- //
- string $mainListConnection = `editor -query -mainListConnection $editor`;
- // Then check to see if this is already connected to the bookmark
- //
- string $objectConnection;
- if ($mainListConnection != "") {
- $objectConnection = `selectionConnection -findObject $bookmark -query $mainListConnection`;
- }
- // See if we want to use this bookmark, or disconnect it
- //
- if ($use) {
- if ($objectConnection == "") {
- // Create a selection connection to wrap this bookmark
- //
- string $connection = `selectionConnection -object $bookmark -parent $editor`;
- // And attach it to the editor
- //
- string $id;
- if ($mainListConnection != "") {
- $id = `selectionConnection -query -identify $mainListConnection`;
- }
- if (($mainListConnection == "") || (($id != "listList") && ($id != "objectList"))) {
- // We can attach it directly
- //
- editor -edit -mainListConnection $connection $editor;
- }
- else if (($id == "listList") && !`selectionConnection -query -switch $mainListConnection`) {
- // There is a list connection that we can attach to
- //
- selectionConnection -edit -add $connection $mainListConnection;
- }
- else {
- // Create a new list connection
- //
- string $listConnection = `selectionConnection -connectionList -parent $editor`;
- editor -edit -mainListConnection $listConnection $editor;
- if ($id == "objectList") {
- selectionConnection -edit -add $mainListConnection $listConnection;
- }
- selectionConnection -edit -add $connection $listConnection;
- }
- }
- }
- else {
- if ($objectConnection != "") {
- if ($objectConnection == $mainListConnection) {
- toggleAutoLoad $editor true;
- }
- else {
- if ($mainListConnection != "") {
- // Remove the objectConnection from the list connection
- //
- selectionConnection -edit -remove $objectConnection $mainListConnection;
- // Check to see if there is anything else still connected
- //
- string $id = `selectionConnection -query -identify $mainListConnection`;
- if ($id == "listList") {
- string $list[] = `selectionConnection -query -connectionList $mainListConnection`;
- if (size ($list) <= 1) {
- toggleAutoLoad $editor true;
- }
- }
- }
- }
- // deleteUI $objectConnection;
- }
- }
- }
-